<?php

namespace Trawind\Remotes\Repositories\Account\Account;

use Trawind\Basics\Enums\ServiceDomain;
use Trawind\Remotes\BaseRepository;
use Trawind\Remotes\Contracts\Repositories\Account\Account\EmployeeRepository;

/**
 * Class CommonRepositoryEloquent.
 * @package namespace TrawindCloud\Repositories\Eloquent;
 */
class EmployeeRepositoryEloquent extends BaseRepository implements EmployeeRepository
{

    public $baseRoute = '/organization/employees';
    /**
     * UserRepositoryEloquent constructor.
     */
    public function __construct()
    {
        $this->domain = ServiceDomain::ACCOUNT_DOMAIN();
    }

    /**
     * @inheritDoc
     */
    public function all($columns = ['*'])
    {
        return $this->setUrl($this->baseRoute)->result();
    }

    /**
     * @inheritDoc
     */
    public function find($id, $columns = ['*'])
    {
        return $this->setUrl($this->baseRoute.'/'.$id)->result();
        
    }

    /**
     * @inheritDoc
     */
    public function create(array $attributes)
    {
        return $this->setUrl($this->baseRoute)
            ->setClientOptions(['form_params' => $attributes])
            ->result('POST');
    }

    /**
     * @inheritDoc
     */
    public function update(array $attributes, $id)
    {
        return $this->setUrl($this->baseRoute.'/'.$id)
            ->setClientOptions(['form_params' => $attributes])
            ->result('PUT');
    }

    /**
     * @inheritDoc
     */
    public function treatmentState(array $ids, $employeeStatus)
    {
        // TODO: Implement treatmentState() method.
    }

    /**
     * @inheritDoc
     */
    public function saveEmployee(array $params)
    {
        // TODO: Implement saveEmployee() method.
    }

    /**
     * @inheritDoc
     */
    public function updateEmployee(array $params, int $id)
    {
        // TODO: Implement updateEmployee() method.
    }

    /**
     * @inheritDoc
     */
    public function deleteEmployee(array $ids)
    {
        // TODO: Implement deleteEmployee() method.
    }


    /**
     * @inheritDoc
     */
    public function subordinate(int $id)
    {
        return $this->setUrl('/organization/employees/staff-relations')->setClientOptions(['query'=>['id'=>$id]])->result();
        //return $this->setUrl('/organization/employee/staff-relations?id='.$id)->result();
    }

    public function getEmployeeIds(int $departmentId, int $companyId)
    {
        return $this->setUrl("/organization/employees/$departmentId/employeeIds/$companyId")->result();
    }

    public function saveLocation(array $params)
    {
        return $this->setUrl($this->baseRoute.'/locations')
            ->setClientOptions(['form_params' =>['address'=>$params]])
            ->result('POST');
    }
}
